using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using HengTong.Model._Admin;

namespace HengTong.Model.Db.SupplyChain.Purchase;

/// <summary>
/// 采购立项主表
/// </summary>
/// <remarks>
/// 用于记录采购立项的主要信息，是连接采购需求池和采购执行的关键环节。
/// 当采购需求池中的需求累积到一定程度，或特定需求需要单独处理时，采购专员将创建采购立项，
/// 明确采购范围、预算、策略和时间要求，经审批后执行采购。
/// </remarks>
[Display(Name = "采购立项", Description = "记录采购立项的主要信息", GroupName = "供应链")]
public class SysPurchaseProject : BaseBill
{
    #region 基本信息

    /// <summary>
    /// 获取或设置立项编号
    /// </summary>
    [Required(ErrorMessage = "立项编号不能为空")]
    [Display(Name = "立项编号", Description = "立项的唯一编号", GroupName = "基本信息")]
    [StringLength(64)]
    public string Code { get; set; }

    /// <summary>
    /// 获取或设置立项名称
    /// </summary>
    /// <value>立项项目名称，简明扼要描述立项内容</value>
    /// <example>2025年11月备品备件集中采购</example>
    [Required(ErrorMessage = "立项名称不能为空")]
    [Display(Name = "立项名称", Description = "立项项目名称", GroupName = "基本信息")]
    [StringLength(128)]
    public string Name { get; set; }

    /// <summary>
    /// 获取或设置立项类型
    /// </summary>
    /// <value>立项类型：常规立项、紧急立项</value>
    [Required(ErrorMessage = "立项类型不能为空")]
    [Display(Name = "立项类型", Description = "立项类型：常规立项、紧急立项", GroupName = "基本信息")]
    public ProjectType? ProjectType { get; set; }

    /// <summary>
    /// 获取或设置立项日期
    /// </summary>
    /// <value>立项创建日期</value>
    [Required(ErrorMessage = "立项日期不能为空")]
    [Display(Name = "立项日期", Description = "立项创建日期", GroupName = "基本信息")]
    public DateTime? ProjectDate { get; set; }
    
    /// <summary>
    /// 获取或设置采购负责人ID
    /// </summary>
    /// <value>采购负责人ID，关联FrameworkUser</value>
    [Required(ErrorMessage = "采购负责人不能为空")]
    [Display(Name = "采购负责人ID", Description = "采购负责人ID", GroupName = "基本信息")]
    public Guid? PurchaserInChargeId { get; set; }

    /// <summary>
    /// 获取或设置采购负责人
    /// </summary>
    /// <value>采购负责人导航属性</value>
    [Display(Name = "采购负责人", Description = "负责执行采购的人员", GroupName = "基本信息")]
    public FrameworkUser PurchaserInCharge { get; set; }
    

    #endregion

    #region 采购策略信息

    /// <summary>
    /// 获取或设置采购策略
    /// </summary>
    /// <value>采购策略：询比价、招投标、协议采购</value>
    [Required(ErrorMessage = "采购策略不能为空")]
    [Display(Name = "采购策略", Description = "采购策略：询比价、招投标、协议采购", GroupName = "采购策略")]
    public PurchaseStrategy? PurchaseStrategy { get; set; }

    /// <summary>
    /// 获取或设置紧急程度
    /// </summary>
    /// <value>紧急程度：一般、紧急（明细中有紧急则自动标记）</value>
    [Required(ErrorMessage = "紧急程度不能为空")]
    [Display(Name = "紧急程度", Description = "紧急程度：一般、紧急", GroupName = "采购策略")]
    public UrgencyLevel? UrgencyLevel { get; set; }

    #endregion

    #region 预算与时间

    /// <summary>
    /// 获取或设置预算总额
    /// </summary>
    /// <value>所有明细预算金额之和，精度2位小数</value>
    [Required(ErrorMessage = "预算总额不能为空")]
    [Display(Name = "预算总额", Description = "所有明细预算金额之和", GroupName = "预算与时间")]
    [Column(TypeName = "decimal(18,2)")]
    public decimal? TotalBudgetAmount { get; set; }

    /// <summary>
    /// 获取或设置预计采购周期
    /// </summary>
    /// <value>预计完成采购的天数</value>
    [Display(Name = "预计采购周期", Description = "预计完成采购的天数", GroupName = "预算与时间")]
    public int? EstimatedPurchaseCycle { get; set; }

    /// <summary>
    /// 获取或设置期望完成日期
    /// </summary>
    /// <value>期望完成采购的截止日期</value>
    [Required(ErrorMessage = "期望完成日期不能为空")]
    [Display(Name = "期望完成日期", Description = "期望完成采购的截止日期", GroupName = "预算与时间")]
    public DateTime? ExpectedCompletionDate { get; set; }

    /// <summary>
    /// 获取或设置最早要货日期
    /// </summary>
    /// <value>所有明细中最早的要求到货日期</value>
    [Required(ErrorMessage = "最早要货日期不能为空")]
    [Display(Name = "最早要货日期", Description = "所有明细中最早的要求到货日期", GroupName = "预算与时间")]
    public DateTime? EarliestRequiredDate { get; set; }

    #endregion

    #region 立项说明

    /// <summary>
    /// 获取或设置立项理由
    /// </summary>
    /// <value>说明立项的必要性和背景，最多1024字符</value>
    [Required(ErrorMessage = "立项理由不能为空")]
    [Display(Name = "立项理由", Description = "说明立项的必要性和背景", GroupName = "立项说明")]
    [StringLength(1024, ErrorMessage = "立项理由不能超过1024个字符")]
    public string ProjectReason { get; set; }

    /// <summary>
    /// 获取或设置技术要求说明
    /// </summary>
    /// <value>整体技术要求（明细有单独技术要求）</value>
    [Display(Name = "技术要求说明", Description = "整体技术要求", GroupName = "立项说明")]
    [Column(TypeName = "nvarchar(max)")]
    public string TechnicalRequirements { get; set; }

    /// <summary>
    /// 获取或设置商务条款说明
    /// </summary>
    /// <value>付款方式、交付条款、质保等要求</value>
    [Display(Name = "商务条款说明", Description = "付款方式、交付条款、质保等要求", GroupName = "立项说明")]
    [Column(TypeName = "nvarchar(max)")]
    public string CommercialTerms { get; set; }

    #endregion

    #region 审批与状态

    /// <summary>
    /// 获取或设置立项状态
    /// </summary>
    /// <value>立项状态：草稿、审批中、已立项、已驳回、已取消、执行中、已完成</value>
    [Required(ErrorMessage = "立项状态不能为空")]
    [Display(Name = "立项状态", Description = "立项状态", GroupName = "审批与状态")]
    public ProjectState? State { get; set; }
    #endregion
    
}

